package br.com.ava.core.pessoa;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import br.com.ava.core.infra.persistencia.ObjetoPersistente;

@Entity
@Table(name = "pessoa")
@Inheritance(strategy = InheritanceType.JOINED)
@SequenceGenerator(name = "idpessoa_seq", sequenceName = "idpessoa_seq", allocationSize = 1)
@SuppressWarnings("serial")
public class Pessoa extends ObjetoPersistente {

	private String nome;
	private String telefone;
	private String email;
	private String endereco;

	public Pessoa() {

	}

	public Pessoa(String nome, String telefone, String email, String endereco) {
		super();
		this.nome = nome;
		this.telefone = telefone;
		this.email = email;
		this.endereco = endereco;
	}

	/** {@inheritDoc} */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO, generator = "idpessoa_seq")
	@Column(name = "idpessoa", nullable = false)
	@Override
	public Integer getId() {
		return id;
	}

	@NotNull
	@Size(max = 45)
	@Column(name = "nome", nullable = false)
	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@NotNull
	@Size(max = 15)
	@Column(name = "telefone", nullable = true)
	public String getTelefone() {
		return telefone;
	}

	public void setTelefone(String telefone) {
		this.telefone = telefone;
	}

	@NotNull
	@Size(max = 45)
	@Column(name = "email", nullable = false)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@NotNull
	@Size(max = 45)
	@Column(name = "endereco", nullable = true)
	public String getEndereco() {
		return endereco;
	}

	public void setEndereco(String endereco) {
		this.endereco = endereco;
	}
}
